import vue from '@vitejs/plugin-vue';
import {
	fileURLToPath,
	URL
} from 'node:url';
import AutoImport from 'unplugin-auto-import/vite';
import {
	ElementPlusResolver
} from 'unplugin-vue-components/resolvers';
import Components from 'unplugin-vue-components/vite';
import {
	defineConfig
} from 'vite';

export default defineConfig({
	plugins: [
		vue(),
		AutoImport({
			resolvers: [ElementPlusResolver()]
		}),
		Components({
			resolvers: [ElementPlusResolver()]
		})
	],
	resolve: {
		alias: {
			'@': fileURLToPath(new URL('./src', import.meta.url))
		}
	},
	optimizeDeps: {
		include: ['@wangeditor/editor-for-vue']
	},
	// css: {
	//   preprocessorOptions: {
	//     scss: {
	//       additionalData: '@import "@/assets/style/mixin.scss";'
	//     }
	//   }
	// },
	server: {
		port: 5173,
		proxy: {
			'/api': {
				target: 'http://1.92.130.32:8888',
				changeOrigin: true,
				rewrite: path => path.replace(/^\/api/, '')
			},
			// '/api': {
			// 	target: 'http://localhost:8888',
			// 	changeOrigin: true,
			// 	rewrite: path => path.replace(/^\/api/, '')
			// },
			'/imgbg': {
				target: 'https://api.anosu.top/img/',
				changeOrigin: true,
				followRedirects: true,
				secure: false, // 忽略证书验证
				rewrite: path => path.replace(/^\/imgbg/, '')
			}
		}
	}
});